/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lucava.importer.uspeed.matcher;

import java.util.regex.Pattern;

/**
 *
 * @author glenn
 */
public class SyntaxPattern {

    public final static String className = "\\[(\\w+)\\]\\s*";
    public final static String multiplicity = "(\\(([\\d\\*]|([\\d\\*]\\.\\.[\\*\\d]))\\)\\s*)";
    public final static String assocType = "([<\\-][>\\+\\-])";
    public final static String noteType = "([.]{2})\\s*";
    public final static String inheritanceType = "([\\^][\\^\\-])";
    public final static String attachedText = "(\\|(.*)\\|\\s*)";
    public final static String arrowType = "([\\-][>\\-])\\s*";
    public final static String comment = "(//((.*)))";
    public final static String modifier = "(((@)([@\\+\\-#])))\\s*";
    public final static String stereotype = "([%]{2})\\s*";
    public final static String memberName = "(\\w+)\\s*";
    public final static String methodArgBlock = "(\\((.*)\\)\\s*)";
    //private final static String methodArgs ="(\\s*((\\w+)(\\s*:\\s*(\\w+)?\\s*)?)\\s*(,\\s*(\\w+)(\\s*:\\s*(\\w+)?\\s*)?)*)+";
    public final static String methodArgs = "(\\s*(\\w+)(\\s*:\\s*(\\w+)?\\s*)?)+";
    public final static String methodReturnType = "(:\\s*((\\w+))\\s*)?";
    /**
     *
     */
    private static Pattern assocPattern = Pattern.compile(
            className //classname
            + assocType + "\\s*" //line type
            + multiplicity + "?" //card source
            + attachedText + "?" //line name
            + multiplicity + "?" //card target
            + arrowType //arrow type
            + className //target class
            );
    private static Pattern inheritancePattern = Pattern.compile(
            className //classname
            + inheritanceType + "\\s*" //line type
            + multiplicity + "?" //card source
            + attachedText + "?" //line name
            + multiplicity + "?" //card target
            + arrowType //arrow type
            + className //target class
            );
    private static Pattern notePattern = Pattern.compile(
            className //classname
            + noteType //line type
            + attachedText + "?" //the note
            );
    private static Pattern methodPattern = Pattern.compile(
            className //classname
            + modifier //type and visibility
            + attachedText + "?" //docblock
            + memberName //name
            + methodArgBlock //method attr
            + methodReturnType //attr type
            );
    private static Pattern attributePattern = Pattern.compile(
            className //classname
            + modifier //type and visibility
            + attachedText + "?" //docblock
            + memberName //name
            + methodReturnType //attr type
            );
    private static Pattern stereotypePattern = Pattern.compile(
            className //classname
            + stereotype //type and visibility
            + attachedText + "?" //docblock
            + memberName //name
            );
    private static Pattern argumentsPattern = Pattern.compile(methodArgs);

    public static Pattern getAssocPattern() {
        return assocPattern;
    }

    public static Pattern getNotePattern() {
        return notePattern;
    }

    public static Pattern getMethodPattern() {
        return methodPattern;
    }

    public static Pattern getAttributePattern() {
        return attributePattern;
    }

    public static Pattern getStereotypePattern() {
        return stereotypePattern;
    }

    public static Pattern getInheritancePattern() {
        return inheritancePattern;
    }

    public static Pattern getArgumentsPattern() {
        return argumentsPattern;
    }
}
